import {Body, Controller, Get, Post, Query, UseGuards} from '@nestjs/common';
import {ImageFieldService} from "./image-field.service";
import {UploadFileDto} from "./dto/uploadFile.dto";
import {AuthGuard} from "@nestjs/passport";

@UseGuards(AuthGuard('jwt'))
@Controller('image')
export class ImageFieldController {
    constructor(private imageService:ImageFieldService ) {}

    @Get('/get-image')
    async getImage(@Query('miniUid') miniUid:string){
        const image=await this.imageService.getImage(miniUid);
        return {
            statusCode: 200,
            res: {
                image
            }
        }
    }

    //严格注意时间格式
    @Post('/push-image')
    async pushImage(@Body() imageInfo:UploadFileDto){
        const res= await this.imageService.pushImage(imageInfo);
        return {
            statusCode: 201,
            res: {
                success: "success",
                res
            }
        }
    }
}
